package com.shigu.validation.impl;

import com.shigu.validation.tags.Telephone;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Pattern;

public class TelephoneValidationImpl implements ConstraintValidator<Telephone,String>{
    @Override
    public void initialize(Telephone constraintAnnotation) {

    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        String telephonePartten="^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$";
        return Pattern.matches(telephonePartten, value);
    }
}
